﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SIA.HwAccess;
using SIA.Configurators;

namespace SIA.Allarms
{
    public class DigitalAllarm : AbstractAllarm, IAllarm
   {
        //private Boolean _statoAttivo = false;
        IDictionaryProperty _allarmProperty;

       public DigitalAllarm(IDictionaryProperty allarmProperty, IDigitalSignal signal)
            :base(allarmProperty, signal)
       {
           _allarmProperty = allarmProperty;
       }

       public override bool isActive
       {
           get { return !(((IDigitalSignal)Signal).DigitalValue ^ Boolean.Parse(_regExp)); }
       }

       public override IAllarm clone()
       {
           DigitalAllarm a = new DigitalAllarm(_allarmProperty, (IDigitalSignal)_signal);
           a._dataOraON = this._dataOraON!=null? new Nullable<DateTime>(this._dataOraON.Value):null;
           a._dataOraOFF = this._dataOraOFF!=null? new Nullable<DateTime>(this._dataOraOFF.Value):null;
           a._dataOraACK = this._dataOraACK != null ? new Nullable<DateTime>(this._dataOraACK.Value) : null;
           a._isActive = this._isActive;
           return a;
       }
   }
}
